package com.beiing.tianshuai.tianshuai.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.beiing.tianshuai.tianshuai.R;
import com.beiing.tianshuai.tianshuai.base.BaseActivity;

import butterknife.BindView;
import cn.bingoogolapple.bgabanner.BGAOnNoDoubleClickListener;

public class PublishInsertUrlActivity extends BaseActivity {

    /**
     * 保存按钮
     */
    @BindView(R.id.toolbar_btn_publish)
    TextView mToolbarBtnSave;

    /**
     * 返回按钮
     */
    @BindView(R.id.toolbar_iv_back)
    ImageView mToolbarBack;

    /**
     * 标题
     */
    @BindView(R.id.toolbar_tv_title)
    TextView mToolbarTitle;

    /**
     * 链接输入框
     */
    @BindView(R.id.et_insert_link)
    EditText mEtInsertLink;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_publish_insert_url;
    }

    @Override
    protected void init() {
        initToolbar();
    }

    /**
     * 初始化Toolbar内容
     */
    private void initToolbar() {
        // 返回按钮
        mToolbarBack.setVisibility(View.VISIBLE);
        mToolbarBack.setOnClickListener(new BGAOnNoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                finish();
            }
        });

        // 标题
        mToolbarTitle.setText("添加视频");

        // 保存
        mToolbarBtnSave.setVisibility(View.VISIBLE);
        mToolbarBtnSave.setText("完成");
        mToolbarBtnSave.setOnClickListener(new BGAOnNoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                String link = mEtInsertLink.getText().toString().trim();
                if (!TextUtils.isEmpty(link)) {
                    Intent intent = new Intent();
                    intent.putExtra("link", link);
                    setResult(NewDiscoveryPublishActivity.RESULT_CODE_INSERT_LINK, intent);
                    finish();
                } else {
                    showShortText("请输入视频链接");
                }
            }
        });
    }
}
